package sueldos;



import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Locale;
import jxl.Workbook;
import jxl.WorkbookSettings;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
 
public class ParseCommaFile{
	
	
	
    public static void main(String[] args) throws IOException, WriteException{
        //Get scanner instance
        
    	//Scanner scanner = new Scanner(new File("c:/users/juani/desktop/movimientos.csv"));
         
        //Set the delimiter used in file
        //scanner.useDelimiter(",");
    	 try
         {
		WritableFont wf = new WritableFont(WritableFont.ARIAL,10, WritableFont.BOLD);
		WritableCellFormat cf = new WritableCellFormat(wf);
		cf.setWrap(false);

		Label l;
		int i=0;
        //Get all tokens and store them in some data structure
        //I am just printing them

       
		BufferedReader fileReader = null;

		//Delimiter used in CSV file
		final String DELIMITER = ",";

		String line = "";
		//Create the file reader
		fileReader = new BufferedReader(new FileReader("c:/users/juani/desktop/movimientos.csv"));

		
		String filename = "c:/aztiriaMovs.xls";
		WorkbookSettings ws = new WorkbookSettings();
		ws.setLocale(new Locale("ar", "ES"));
		WritableWorkbook workbook = Workbook.createWorkbook(new File(filename), ws);
		WritableSheet s = workbook.createSheet("Movimientos", 0);
 
		
		//Read the file line by line
		while ((line = fileReader.readLine()) != null)
		{
			//Get all tokens available in line
			String[] tokens = line.split(DELIMITER);

			for (int j = 0; j < tokens.length; j++) {
				l = new Label(j,i,tokens[j].toString()); //fecha de ingreso
				s.addCell(l);

			}
			i++;
		}

            
            
            
            
            
            
            
            
    		workbook.write();
    		workbook.close();  
    		

        }
        catch (Exception e) {
            e.printStackTrace();
        }
        
        
 
    }
}